Skip to content

fix: skip proxy-only plugin initialization for CLI subcommands#1724

Draft
waldekmastykarz wants to merge 2 commits into
dotnet:mainfrom
waldekmastykarz:waldekmastykarz-fix-devtools-browser-cli-commands
Draft

fix: skip proxy-only plugin initialization for CLI subcommands#1724
waldekmastykarz wants to merge 2 commits into
dotnet:mainfrom
waldekmastykarz:waldekmastykarz-fix-devtools-browser-cli-commands

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1722

When running CLI subcommands (e.g., devproxy jwt create), plugins like DevToolsPlugin would still fully initialize — opening a browser window. This PR adds an IsProxyCommand property to InitArgs so plugins can skip initialization that is only relevant when the proxy is actually running.

Changes

  • DevProxy.Abstractions/Proxy/ProxyEvents.cs — Added IsProxyCommand to InitArgs (defaults to true for backwards compatibility)
  • DevProxy/Plugins/PluginServiceExtensions.cs — Passes DevProxyCommand.IsRootCommand when constructing InitArgs
  • DevProxy.Plugins/Inspection/DevToolsPlugin.cs — Skips browser initialization when not the proxy command
  • DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs — Skips OTLP exporter/file watcher initialization when not the proxy command

Backwards compatibility

IsProxyCommand defaults to true, so existing external plugins continue to work unchanged.

Add IsProxyCommand property to InitArgs so plugins can conditionally
skip initialization that is only relevant for proxy operation (e.g.,
opening browsers, starting telemetry listeners) when running CLI
subcommands like 'devproxy jwt create'.

Update DevToolsPlugin and OpenAITelemetryPlugin to check this flag
before performing their proxy-only initialization.

Closes dotnet#1722

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 19, 2026 06:51
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner June 19, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #1722 by adding an IsProxyCommand flag to plugin initialization so plugins can skip proxy-only initialization (eg. launching a browser / starting telemetry exporters) when Dev Proxy is invoked via CLI subcommands (eg. devproxy jwt create) rather than actually running the proxy.

Changes:

  • Added InitArgs.IsProxyCommand (defaulting to true for compatibility) to let plugins know whether the proxy is being started.
  • Passed an IsProxyCommand value when initializing plugins from the host.
  • Updated DevToolsPlugin and OpenAITelemetryPlugin to return early when IsProxyCommand is false.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
DevProxy.Abstractions/Proxy/ProxyEvents.cs Adds IsProxyCommand to InitArgs with XML documentation and a default value.
DevProxy/Plugins/PluginServiceExtensions.cs Passes IsProxyCommand into InitializeAsync when constructing plugins.
DevProxy.Plugins/Inspection/DevToolsPlugin.cs Skips browser/inspector initialization when not running the proxy command.
DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs Skips telemetry/exporter initialization when not running the proxy command.

Comment thread DevProxy/Plugins/PluginServiceExtensions.cs
Comment thread DevProxy/Plugins/PluginServiceExtensions.cs
@waldekmastykarz

Copy link
Copy Markdown
Collaborator Author

The build failure is pre-existing on maindotnet restore --locked-mode fails due to NU1903 (warning-as-error) for SQLitePCLRaw.lib.e_sqlite3 2.1.11 (GHSA-2m69-gcr7-jv3q). This is unrelated to the changes in this PR. Marking as draft until the dependency update is merged.

@waldekmastykarz waldekmastykarz marked this pull request as draft June 19, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DevToolsPlugin opens browser when running CLI commands

2 participants